<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="学校编号" prop="schoolId">
        <el-input
          v-model="queryParams.schoolId"
          placeholder="请输入学校编号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年级编号" prop="gradeId">
        <el-input
          v-model="queryParams.gradeId"
          placeholder="请输入年级编号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班级编号" prop="classId">
        <el-input
          v-model="queryParams.classId"
          placeholder="请输入班级编号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学生姓名" prop="studentName">
        <el-input
          v-model="queryParams.studentName"
          placeholder="请输入学生姓名"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['order:order:export']"
          >导出</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="signupList">
      <el-table-column label="游泳馆名称" align="center" prop="swimPlaceName" />
      <el-table-column
        label="游泳课班级"
        align="center"
        prop="swimPlaceClassName"
      />
      <el-table-column label="课程名称" align="center" prop="courseName" />
      <el-table-column label="上课日期" align="center">
        <template #default="scope">
          {{ scope.row.courseStartDate }} ~ {{ scope.row.courseEndDate }}
        </template>
      </el-table-column>
      <el-table-column label="上课时间" align="center">
        <template #default="scope">
          {{ scope.row.courseStartTime }} ~ {{ scope.row.courseEndTime }}
        </template>
      </el-table-column>
      <el-table-column label="学校" align="center" prop="schoolName" />
      <el-table-column label="年级" align="center" prop="gradeName" />
      <el-table-column label="班级" align="center" prop="className" />
      <el-table-column label="学生" align="center" prop="studentName" />
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button link type="primary" icon="View" @click="handleUpdate(scope.row)" v-hasPermi="['course:courseSignup:edit']">查看</el-button>
          </template>
        </el-table-column> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="Signup">
import { listSignupOrder } from "@/api/order/order";

const { proxy } = getCurrentInstance();

const signupList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    schoolId: null,
    gradeId: null,
    classId: null,
    studentName: null,
  },
  rules: {},
});

const { queryParams, form, rules } = toRefs(data);

/** 查询课程报名列表 */
function getList() {
  loading.value = true;
  listSignupOrder(queryParams.value).then((response) => {
    signupList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 导出按钮操作 */
const handleExport = () => {
  proxy.download(
    "admin/order/order/exportCourseSignup",
    {
      ...queryParams.value,
    },
    `课程包名_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
